﻿CREATE PROCEDURE [dbo].[proc_Roles_Update]
	(
	@RoleName nvarchar(50),
	@Description nvarchar(265),
	@Sort int,
	@FAdminFlg bit,
	@RoleId int,
	@AppActions nvarchar(2000)
	)
AS
begin
	Update aspnet_Roles Set RoleName=@RoleName,Description=@Description,Sort=@Sort,FAdminFlg=@FAdminFlg Where RoleId=@RoleId
	Delete RoleGroupAppList Where RoleId=@RoleId
	Declare @i int
	Set @i=0
	while(@i<len(@AppActions))
	begin
		Insert Into RoleGroupAppList(RoleId,SysAppId)Values(@RoleId, substring(@AppActions,@i,charindex(',',@AppActions,@i)-@i))
		Set @i=charindex(',',@AppActions,@i)+1
	end
end
	RETURN
